import 'package:zpp_sdzx/helper/Helper.dart';

import '../helper/cacheHelper.dart';

import '../helper/dioHelper.dart';

class ShipUse {
  int ID;
  String Guid;
  String Title;
  String Department;
  String UseTime;
  String Content;
  String Members;
  String ZBYName;
  String ZBYPhone;
  String CreateTime;
  String BMName;
  String BMQM;
  String BMPhone;
  String BMTM;
  bool BMIfOK;
  String HDQM;
  String HDTM;
  String HDUserID;
  bool HDIfOK;
  String SYQM;
  String SYTM;
  String SYUserID;
  bool SYIfOK;
  String LDQM;
  String LDTM;
  String LDUserID;
  bool LDIfOK;
  String ManaName;
  String ManaPhone;
  String ManaName2;
  String CZName;
  String CZName2;
  String CZPhone;
  String ChuanBo;
  String ChuanBo2;
  String UseTime2;
  String UsePath2;
  int Peoples;
  double Length;
  String TianQi;
  String HangXing;
  String CunDang;
  String HZTM;
  String HZQM;
  String HZSHTM;
  String HZUserID;
  bool HZIfOK;
  int State;
  String Remark;

  ShipUse(
      this.ID,
      this.Guid,
      this.Title,
      this.Department,
      this.UseTime,
      this.Content,
      this.Members,
      this.ZBYName,
      this.ZBYPhone,
      this.CreateTime,
      this.BMName,
      this.BMQM,
      this.BMPhone,
      this.BMTM,
      this.BMIfOK,
      this.HDQM,
      this.HDTM,
      this.HDUserID,
      this.HDIfOK,
      this.SYQM,
      this.SYTM,
      this.SYUserID,
      this.SYIfOK,
      this.LDQM,
      this.LDTM,
      this.LDUserID,
      this.LDIfOK,
      this.ManaName,
      this.ManaPhone,
      this.ManaName2,
      this.CZName,
      this.CZName2,
      this.CZPhone,
      this.ChuanBo,
      this.ChuanBo2,
      this.UseTime2,
      this.UsePath2,
      this.Peoples,
      this.Length,
      this.TianQi,
      this.HangXing,
      this.CunDang,
      this.HZTM,
      this.HZQM,
      this.HZSHTM,
      this.HZUserID,
      this.HZIfOK,
      this.State,
      this.Remark);
  ShipUse.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        Guid = json["Guid"],
        Title = json["Title"],
        Department = json["Department"],
        UseTime = json["UseTime"],
        Content = json["Content"],
        Members = json["Members"],
        ZBYName = json["ZBYName"],
        ZBYPhone = json["ZBYPhone"],
        CreateTime = json["CreateTime"],
        BMName = json["BMName"],
        BMQM = json["BMQM"],
        BMPhone = json["BMPhone"],
        BMTM = json["BMTM"],
        BMIfOK = json["BMIfOK"],
        HDQM = Helper.toStr(json["HDQM"]),
        HDTM = json["HDTM"],
        HDUserID = json["HDUserID"],
        HDIfOK = json["HDIfOK"],
        SYQM = Helper.toStr(json["SYQM"]),
        SYTM = Helper.toStr(json["SYTM"]),
        SYUserID = Helper.toStr(json["SYUserID"]),
        SYIfOK = json["SYIfOK"],
        LDQM = Helper.toStr(json["LDQM"]),
        LDTM = Helper.toStr(json["LDTM"]),
        LDUserID = Helper.toStr(json["LDUserID"]),
        LDIfOK = json["LDIfOK"],
        ManaName = Helper.toStr(json["ManaName"]),
        ManaPhone = Helper.toStr(json["ManaPhone"]),
        ManaName2 = Helper.toStr(json["ManaName2"]),
        CZName = Helper.toStr(json["CZName"]),
        CZName2 = Helper.toStr(json["CZName2"]),
        CZPhone = Helper.toStr(json["CZPhone"]),
        ChuanBo = Helper.toStr(json["ChuanBo"]),
        ChuanBo2 = Helper.toStr(json["ChuanBo2"]),
        UseTime2 = Helper.toStr(json["UseTime2"]),
        UsePath2 = Helper.toStr(json["UsePath2"]),
        Peoples = Helper.toInt(json["Peoples"]),
        Length = json["Length"],
        TianQi = Helper.toStr(json["TianQi"]),
        HangXing = Helper.toStr(json["HangXing"]),
        CunDang = Helper.toStr(json["CunDang"]),
        HZTM = Helper.toStr(json["HZTM"]),
        HZQM = Helper.toStr(json["HZQM"]),
        HZSHTM = Helper.toStr(json["HZSHTM"]),
        HZUserID = Helper.toStr(json["HZUserID"]),
        HZIfOK = json["HZIfOK"],
        State = Helper.toInt(json["State"]),
        Remark = Helper.toStr(json["Remark"]);
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'Guid': Guid,
        'Title': Title,
        'Department': Department,
        'UseTime': UseTime,
        'Content': Content,
        'Members': Members,
        'ZBYName': ZBYName,
        'ZBYPhone': ZBYPhone,
        'CreateTime': CreateTime,
        'BMName': BMName,
        'BMQM': BMQM,
        'BMPhone': BMPhone,
        'BMTM': BMTM,
        'BMIfOK': BMIfOK,
        'HDQM': HDQM,
        'HDTM': HDTM,
        'HDUserID': HDUserID,
        'HDIfOK': HDIfOK,
        'SYQM': SYQM,
        'SYTM': SYTM,
        'SYUserID': SYUserID,
        'SYIfOK': SYIfOK,
        'LDQM': LDQM,
        'LDTM': LDTM,
        'LDUserID': LDUserID,
        'LDIfOK': LDIfOK,
        'ManaName': ManaName,
        'ManaPhone': ManaPhone,
        'ManaName2': ManaName2,
        'CZName': CZName,
        'CZName2': CZName2,
        'CZPhone': CZPhone,
        'ChuanBo': ChuanBo,
        'ChuanBo2': ChuanBo2,
        'UseTime2': UseTime2,
        'UsePath2': UsePath2,
        'Peoples': Peoples,
        'Length': Length,
        'TianQi': TianQi,
        'HangXing': HangXing,
        'CunDang': CunDang,
        'HZTM': HZTM,
        'HZQM': HZQM,
        'HZSHTM': HZSHTM,
        'HZUserID': HZUserID,
        'HZIfOK': HZIfOK,
        'State': State,
        'Remark': Remark,
      };
  static Future<bool> Add(ShipUse x1) async {
    var response = await DioHelper.Post("/ShipUse/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(ShipUse x1) async {
    var response = await DioHelper.Post("/ShipUse/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(ShipUse x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/ShipUse/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<ShipUse?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/ShipUse/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200) return new ShipUse.fromJson(response.data);
    return null;
  }

  static Future<List<ShipUse>> GetList(
      String where, dynamic data, int pageIndex, int pageSize) async {
    var response = await DioHelper.Post("/ShipUse/GetListByWhere", {
      "Where": where,
      "obj": data,
      "PageIndex": pageIndex,
      "PageSize": pageSize,
    });
    var list1 = <ShipUse>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new ShipUse.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<ShipUse>> GetAllList() async {
    var response = await DioHelper.Get("/ShipUse/GetAllList", {});
    var list1 = <ShipUse>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new ShipUse.fromJson(x));
      }
    }
    return list1;
  }

  static Future<String?> SendById(
      String title, String content, String userId) async {
    var u1 = CacheHelper.GetUser(userId);
    var id = u1.JPushID;
    var phone = u1.Phone;

    var response = await DioHelper.Get2("http://47.95.205.213:22351",
        "/notice?id=$id&content=$content&phone=$phone", {
      "Where": "",
    });

    if (response.statusCode == 200) return response.data;
    return null;
  }

  static Future<String?> SendByPhone(
      String title, String content, String phone) async {
    //return null;

    var response = await DioHelper.Get2(
        "http://47.95.205.213:22351", "/notice?content=$content&phone=$phone", {
      "Where": "",
    });

    if (response.statusCode == 200) return response.data;
    return null;
  }

  static Future<String?> SendById2(
      String title, String content, String userId) async {
    return null;
  }
}
